package com.example.demo.mapper;

import com.example.demo.dto.SearchInfo;
import com.example.demo.entity.Yunshugongju;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository()
public interface Yunshugongju_Mapper extends BaseMapper<Yunshugongju>{
	
	@Select("SELECT Yunshugongju.* ,zhigong.name zhigongname"
	        + " FROM Yunshugongju inner join zhigong on  Yunshugongju.zhigongid = zhigong.id  ${where} ${limitstr}")
	public List<Yunshugongju> select(SearchInfo info);
	
	@Select("SELECT COUNT(1) FROM Yunshugongju ${where}")
	public long selectCount(SearchInfo info);
	
	@Insert("INSERT INTO Yunshugongju (chepaihao, zhigongid,cheliangleixing) VALUES (#{chepaihao},  #{zhigongid},#{cheliangleixing})")
	public void insert(Yunshugongju Yunshugongju);
	
	@Update("UPDATE Yunshugongju SET chepaihao = #{chepaihao}, zhigongid = #{zhigongid}, "
	        + "cheliangleixing = #{cheliangleixing} WHERE id = #{id}")
	public void update(Yunshugongju Yunshugongju);
	
	
	@Delete("DELETE FROM Yunshugongju WHERE id = #{id}")
	public void delete(int id);
	
	@Select("SELECT * FROM Yunshugongju WHERE id = #{id}")
	public Yunshugongju selectById(int id);
	
}
